#!/bin/sh

#OPT=-O2
DEBUG=-g
CFLAGS=-Wall -Wno-format -fPIC $(OPT) $(DEBUG) -DHAVE_EPOLL -I./

CC=g++
LCOMMON=-lrt -lpthread -ltimers -L./

ifeq ($(GOOGPERF),yes)
PROFILER=-DGOOG_PROFILER
LPROFILER=-lprofiler
endif


OBJS=NetAddr.o EventHub.o Common.o


all: libcuttdb.so libcuttdb.a


#cdb_builddb: cdb_builddb.o libcuttdb.a
#	$(CC) $(CFLAGS) -o $@ $^ $(LCOMMON)


#cuttdb-server: cuttdb-server.o server-thread.o libcuttdb.a
#$(CC) -o $@ $^ $(LCOMMON)


libcuttdb.so: $(OBJS)
	$(CC) -shared -o $@ $^ $(LPROFILER) $(LCOMMON) 


libcuttdb.a: $(OBJS)
	ar cqs $@ $^  


%.o: %.cpp
	$(CC) -c $(CFLAGS) -o $@ $^ $(PROFILER)


clean:
	rm -rf *.o libcuttdb.so libcuttdb.a 


cleanobj:
	rm -rf *.o

                                                                                      
rebuild: clean all

